package Classes.Components
{
	import Classes.Entity;
	import Classes.Skill;

	public class PlayerComponent extends BaseComponent
	{
		public function PlayerComponent(entity:Entity)
		{
			super(entity);
		}
		
		override public function update(delta:int):void{
			if(m_entity.getRigidBodyComponent().isMoving()){
				testForAggro();
			}
		}
		
		private function testForAggro():void{
			var mobs:Vector.<Entity> = m_entity.getRigidBodyComponent().getMobsInRadius(2);
			var i:int;
			var length:int = mobs.length;
			for(i=0;i<length;i++){
				var mob:Entity = mobs[i];
				if(!mob.getAIComponent().isEngaged() && mob.getAIComponent().testAggroRange(m_entity)){
					var skill:Skill = mob.getSkillComponent().getSkillByName('standard_attack',m_entity);
					Main.actionManager.addSkillAction(skill);					
				}
			}
		}
	}
}